package com.cs456.TeamBobcat;

import java.io.IOException;
import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.media.ExifInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.cs456.TeamBobcat.database.Constants;
import com.cs456.TeamBobcat.database.MyDB;
import com.cs456.TeamBobcat.views.StaticMapLayout;

public class WhereAmIHistory  extends Activity {
	private static String TAG = "WhereAmIHistory";
	StaticMapLayout _map;
	Button _homeButton;
	MyDB dba;
	int imageSize;
	protected ArrayList <String> _pathBag;

	double[] GPS;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Log.d(TAG, "onCreate");
		
		setContentView(R.layout.whereamiresult);
		dba = new MyDB(this);
        dba.open();
        

		initGPSMap();
		initHomeButton();

	}

	private void initHomeButton() {
		_homeButton = (Button) findViewById(R.id.WAIResult_Home);
		_homeButton.setOnClickListener(new OnClickListener() {

			public void onClick(View v) {
				finish();
			}
		});
	}

	private void initGPSMap() {
		_map = (StaticMapLayout) findViewById(R.id.WAIResult_Text);
		_map.setMap(R.drawable.map2, 39.343989f, -82.120829f, 39.312851f, -82.079802f);

		Cursor prevLocs = dba.getgps();
		prevLocs.moveToFirst();
        while (prevLocs.isAfterLast() == false) {
        	int latIndex = prevLocs.getColumnIndex(Constants.GPS_X);
        	int longIndex = prevLocs.getColumnIndex(Constants.GPS_Y);
        	
        	float lat = prevLocs.getFloat(latIndex);
        	float lon = prevLocs.getFloat(longIndex);
            _map.addPastLocation(lat, lon);
            prevLocs.moveToNext();
        }		
		

	}

}
